/* 
 * DataStructures.h
 *
 * Created: 09/03/2014 07:39:15
 * Author: Jason
 * Data definitions and structures for both processors.
 *
 */ 


#ifndef DATASTRUCTURES_H_
#define DATASTRUCTURES_H_

#ifdef __cplusplus  
  extern "C" {
#endif

#define CONFIG_ROBOTFUNCTION_WAITFORUSER 0
#define CONFIG_ROBOTFUNCTION_LINEFOLLOWER 1
#define CONFIG_ROBOTFUNCTION_WALLFOLLOWER 2
#define CONFIG_ROBOTFUNCTION_DRAGRACE 3
#define CONFIG_ROBOTFUNCTION_MAZESOLVE 4
#define CONFIG_ROBOTFUNCTION_MAZESPEEDRUN 5
#define CONFIG_ROBOTFUNCTION_LINECALIBRATE 6
#define CONFIG_ROBOTFUNCTION_WALLCALIBRATE 7

#define CONFIG_LINECOLOUR_BLACK 1
#define CONFIG_LINECOLOUR_WHITE 1

// SPI commands to define what chunk of data is about to move in what direction.
#define SPICMD_REQUEST_LINEDATA 2
#define SPICMD_REQUEST_WALLDATA 3
#define SPICMD_REQUEST_BUTTONDATA 4
#define SPICMD_REQUEST_RF_STRING 5
#define SPICMD_SEND_RF_STRING 6
#define SPICMD_SEND_OLED_STRING 7
#define SPICMD_SEND_ROBOTFUNCTION 8
#define SPICMD_SEND_LEDDATA 9

typedef struct mode_type
{
  uint8_t robotFunction;
  uint8_t dataFresh;
} mode_type;

typedef struct config_type
{
  uint8_t lineColour;
  uint8_t topStraightSpeedAdjust;
  uint8_t topRightAngleSpeedAdjust;
  uint8_t topCurve1SpeedAdjust;
  uint8_t topCurve2SpeedAdjust;
  uint8_t topCurve3SpeedAdjust;
  uint8_t lineSensorCalibrationLevelLow;
  uint8_t lineSensorCalibrationLevelHigh;
  uint16_t wheelResolution;
  uint16_t wheelCircumfrence;

} config_type;

typedef struct lineSensorData_type
{
  uint8_t sensor1;
  uint8_t sensor2;
  uint8_t sensor3;
  uint8_t sensor4;
  uint8_t sensor5;
  uint8_t dataFresh;
} lineSensorData_type;

typedef struct linePositionData_type
{
  signed char linePosition;
  uint8_t LeftMarker;
  uint8_t RightMarker;
  uint8_t dataFresh;
} linePositionData_type;


typedef struct wallSensorData_type
{
  uint8_t sensor1;
  uint8_t sensor2;
  uint8_t sensor3;
  uint8_t sensor4;
  uint8_t sensor5;
  uint8_t sensor6;
  uint8_t dataFresh;
} wallSensorData_type;

#define HCIDATA_LEDSTATE_ON 1         // on or off
#define HCIDATA_LEDSTATE_HEARTBEAT 2  // heartbeat or always on
#define HCIDATA_LEDSTATE_FAST 4       // fast heartbeat or slow
#define HCIDATA_LEDState_BALANCED 8   // 75:25 or 50:50
#define HCIDATA_LEDState_INVERTED 16  // mostly on or mostly off

#define HCIDATA_BUTTONPRESSEDEVENT_BUTTON1_SHORTPRESS 1
#define HCIDATA_BUTTONPRESSEDEVENT_BUTTON1_SHORTPRESS 2
#define HCIDATA_BUTTONPRESSEDEVENT_BUTTON2_LONGPRESS 3
#define HCIDATA_BUTTONPRESSEDEVENT_BUTTON2_LONGPRESS 4
#define HCIDATA_BUTTONPRESSEDEVENT_BUTTON1AND2_LONGPRESS 5  //system reset

typedef struct buttonData_type
{
  uint8_t btnPressedEvent;
  uint8_t dataFresh;
} buttonData_type;  

typedef struct LEDData_type
{
  uint8_t LED1State;
  uint8_t LED2State;
  uint8_t dataFresh;
} LEDData_type;  
 
typedef struct MotorData_type
{
  signed char LeftSpeed;
  signed char RightSpeed;
  uint8_t dataFresh;
} MotorData_type;

typedef struct stringData_type
{
  unit8_t data[20];
}stringData_type;

#ifdef __cplusplus
  }
#endif

#endif /* DATASTRUCTURES_H_ */